<?php

namespace App\Controller\Admin;

use App\Controller\ApiController;
use Hyperf\Di\Annotation\Inject;
use Hyperf\Logger\LoggerFactory;
use Psr\Log\LoggerInterface;
use App\Logic\Admin\ActionLogLogic;
use Throwable;

class ActionLogController extends ApiController
{
    #[Inject]
    protected LoggerInterface $logger;
    #[Inject]
    protected ActionLogLogic $actionLogLogic;
    public function __construct(LoggerFactory $loggerFactory)
    {
        parent::__construct($loggerFactory);
        $this->actionLogLogic = new ActionLogLogic();
    }

    /**
     * Notes:获取日志列表
     * 2025/7/17
     * @return \Psr\Http\Message\ResponseInterface
     */
    public function logs(): \Psr\Http\Message\ResponseInterface
    {
        try {
            $size = $this->request->post('limit',20);
            $result = $this->actionLogLogic->logs($size);
            return $this->responseSuccess($result);
        }catch (Throwable $throwable){
            return $this->responseError($throwable->getCode(),$throwable->getLine(),$throwable->getFile() ,$throwable->getMessage());
        }
    }
}